From 9507dd99c096281bbb2d080a2d22d2ffc61c7dd9 Mon Sep 17 00:00:00 2001 From: Jonathan Dieter Date: Tue, 10 Apr 2018 16:00:04 +0300 Subject: [PATCH] Add ability to get index based on file location Signed-off-by: Jonathan Dieter --- src/lib/index/index_common.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib/index/index_common.c b/src/lib/index/index_common.c index 04917d3..396c6c1 100644 --- a/src/lib/index/index_common.c +++ b/src/lib/index/index_common.c @@ -31,6 +31,18 @@ #include "zck_private.h" +zckIndexItem *zck_get_index_of_loc(zckIndex *index, size_t loc) { + zckIndexItem *idx = index->first; + while(idx != NULL) { + if(loc >= idx->start && loc < idx->start + idx->comp_length) + return idx; + idx = idx->next; + } + zck_log(ZCK_LOG_ERROR, "Unable to find index that contains position %lu\n", + loc); + return NULL; +} + void zck_index_free_item(zckIndexItem **item) { if(*item == NULL) return; -- 2.30.2